
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

using TwitterClient;

namespace SigTweet
{
	public partial class TweetDetailViewController : UIViewController
	{
		#region Constructors

		// The IntPtr and NSCoder constructors are required for controllers that need 
		// to be able to be created from a xib rather than from managed code

		public TweetDetailViewController (IntPtr handle) : base(handle)
		{
			Initialize ();
		}

		[Export("initWithCoder:")]
		public TweetDetailViewController (NSCoder coder) : base(coder)
		{
			Initialize ();
		}

		public TweetDetailViewController () : base("TweetDetailViewController", null)
		{
			Initialize ();
		}

		void Initialize ()
		{
		}

		#endregion

		public Tweet CurrentTweet { get; set; }

		public override void ViewWillAppear (bool animated)
		{
			BindToCurrentTweet ();
			base.ViewWillAppear (animated);
		}

		private void BindToCurrentTweet ()
		{
			if (CurrentTweet != null) {
				tweetBy.Text = String.Format ("{0} says...", CurrentTweet.PostedBy);
				tweetDate.Text = CurrentTweet.PostedAt.ToString ("D");
				tweetTime.Text = CurrentTweet.PostedAt.ToString ("h:mm tt");
				tweetContent.Text = CurrentTweet.UpdateText;
			}
		}
	}
}
